package edu.ubb.scrumster.model.repository;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import edu.ubb.scrumster.model.model.AbstractModel;
import edu.ubb.scrumster.model.model.Project;
import edu.ubb.scrumster.model.model.Scrum;
import edu.ubb.scrumster.model.model.User;

public class ScrumRepository {

	public ScrumRepository() {
	}

	public ArrayList<Scrum> getAllScrum() {
		ArrayList<Scrum> list = new ArrayList<Scrum>();
		for (AbstractModel d : DatabaseAccess.getInstance().getAll(DatabaseAccess.SCRUM)){
			list.add(getScrumById(((Scrum) d).getId()));
		}
		return list;
	}

	public void addScrum(Scrum g) {
		DatabaseAccess.getInstance().addData(g);
	}

	public void updateScrum(Scrum data) {
		DatabaseAccess.getInstance().updateData(data);
	}

	public void deleteScrum(Scrum data) {
		DatabaseAccess.getInstance().deleteData(data);
	}

	public Scrum getScrumById(int id) {
		Scrum s=(Scrum)DatabaseAccess.getInstance().getDataById(id, DatabaseAccess.SCRUM);
		s.setProject((Project)DatabaseAccess.getInstance().getDataById(s.getProject().getId(), DatabaseAccess.PROJECT));
		return s;
	}
}
